package org.ruoyi.data.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.ruoyi.common.core.domain.R;
import org.ruoyi.common.core.validate.AddGroup;
import org.ruoyi.common.core.validate.EditGroup;
import org.ruoyi.common.excel.utils.ExcelUtil;
import org.ruoyi.common.idempotent.annotation.RepeatSubmit;
import org.ruoyi.common.log.annotation.Log;
import org.ruoyi.common.log.enums.BusinessType;
import org.ruoyi.common.mybatis.core.page.PageQuery;
import org.ruoyi.common.mybatis.core.page.TableDataInfo;
import org.ruoyi.common.web.core.BaseController;
import org.ruoyi.data.domain.bo.DataHandleBo;
import org.ruoyi.data.domain.bo.DataTableBo;
import org.ruoyi.data.domain.vo.DataTableVo;
import org.ruoyi.data.service.IDataTableService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 数据查询处理
 *
 * @author bz_huaYal9146
 * @date 2025-11-04
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/handle/data")
public class DataHandleController extends BaseController {

    private final IDataTableService dataTableService;

    /**
     * 查询数据列表(后台)
     */
    @PostMapping("/getData")
    public R getData(@RequestBody DataHandleBo bo) {

        return dataTableService.getData(bo, false);
    }

    /**
     * 查询数据列表（智能体）
     */
    @PostMapping("/getDataAi")
    public R getDataAi(@RequestBody DataHandleBo bo) {

        return dataTableService.getData(bo, true);
    }

    /**
     * 查询影响因子
     */
    @PostMapping("/getDataFormula")
    public String getDataFormula(@RequestBody DataHandleBo bo) {
        String formula = "";
        R r = dataTableService.getDataFormula(bo);
        if (R.isSuccess(r)) {
            if (r.getData() != null){
                formula = r.getData().toString();
            }
        }
        return formula;
    }


}
